//
//  SLHTTPClient.h
//  LSNets
//
//  Created by Samuel on 12/9/14.
//
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "AFURLSessionManager.h"

#ifdef DEBUG
#define LOG 0
#else
#define LOG 0
#endif

#if LOG
#define SNLog(fmt, ...) NSLog((@"\n方法名%s;\n\n行数：[Line %d];\n\n" fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define SNLog(fmt, ...)
#endif


@class SDebugWindow;
@interface SHTTPClient : NSObject

@property (nonatomic, assign)BOOL isOpneRecordRequest;
@property (nonatomic, weak)UIView *sDwindow;

+ (SHTTPClient *)sharedClient;
/**
 *  Get ios7~ios8
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
+ (void)GetBaseForConnection:(NSString *)path
                 _Parameters:(NSMutableDictionary *)parameters
                       block:(void(^)(id rDictionary))processResult
                   failblock:(void(^)(NSError *error))failResult;
/**
 *  Post ios7~ios8
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
+ (void)PostBaseForConnection:(NSString *)path
                  _Parameters:(NSMutableDictionary *)parameters
                        block:(void(^)(id rDictionary))processResult
                    failblock:(void(^)(NSError *error))failResult;





/**
 *  自定义文件请求
 *
 *  @param data        data
 *  @param url           url
 *  @param path          path
 *  @param parameters    dictionary
 *  @param processResult
 *  @param failResult
 */
+ (void)coustomRequestOfData:(NSData*)data
                    DataName:(NSString*)dataName
                         Url:(NSString*)url
                        Path:(NSString*)path
                  Parameters:(NSMutableDictionary*)parameters
                        Type:(NSString*)type
                       block:(void(^)(id rDictionary))processResult
                   failblock:(void(^)(NSError *error))failResult;
+ (AFHTTPSessionManager*)sharedSessionByCoustom:(NSString*)urls;

@end

/******************************************* 用于ios7以上 基于AFN的NSURLSession封装 *******************************************/

@interface SHTTPSessionClient : AFHTTPSessionManager
/**
 *  初始化 Session （不兼容ios6）
 *
 *  @return
 */
+ (SHTTPSessionClient *)sharedSessionClientWithUrl:(NSString*)urls;
/**
 *  Session Post 请求 （不兼容ios6）
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
- (void)POST_Path_Session:(NSString *)path
              _Parameters:(NSMutableDictionary *)parameters
                    block:(void(^)(id rDictionary,NSURLSessionDataTask *rTask))processResult
                failblock:(void(^)(NSError *error,NSURLSessionDataTask *rTask))failResult;
/**
 *  Session Get 请求 （不兼容ios6）
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
- (void)GET_Path_Session:(NSString *)path
             _Parameters:(NSMutableDictionary *)parameters
                   block:(void(^)(id rDictionary,NSURLSessionDataTask *rTask))processResult
               failblock:(void(^)(NSError *error,NSURLSessionDataTask *rTask))failResult;
/**
 *  Session Post 文件请求 （不兼容ios6）
 *
 *  @param path
 *  @param parameters
 *  @param picurls
 *  @param processResult
 *  @param failResult
 */
- (void)POST_Path_File_Session:(NSString *)path
                   _Parameters:(NSMutableDictionary *)parameters
                     _DataUrls:(NSString*)dataUrls
                   _UpDataUrls:(NSString*)upDataUrls
                         block:(void (^)(id, NSURLSessionDataTask *))processResult
                     failblock:(void (^)(NSError *, NSURLSessionDataTask *))failResult;
@end

/******************************************* 通用于ios各版本 基于AFN的NSURLConnection封装 *******************************************/

@interface SHTTPConnectionClient : AFHTTPRequestOperationManager
/**
 *  初始化OperationManager
 *
 *  @return
 */
+(SHTTPConnectionClient *)sharedConnectionClientWithUrl:(NSString*)urls;
/**
 *  OperationManager Post 请求（通用与ios6~ios8）
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
- (void)POST_Path_Connection:(NSString *)path
                 _Parameters:(NSMutableDictionary *)parameters
                       block:(void(^)(id rDictionary,AFHTTPRequestOperation *rOperation))processResult
                   failblock:(void(^)(NSError *error,AFHTTPRequestOperation *rOperation))failResult;
/**
 *  OperationManager Get 请求（通用与ios6~ios8）
 *
 *  @param path
 *  @param parameters
 *  @param processResult
 *  @param failResult
 */
- (void)GET_Path_Connection:(NSString *)path
                _Parameters:(NSMutableDictionary *)parameters
                      block:(void(^)(id rDictionary,AFHTTPRequestOperation *rOperation))processResult
                  failblock:(void(^)(NSError *error,AFHTTPRequestOperation *rOperation))failResult;

@end